package com.daidai.cdc;

import com.ververica.cdc.connectors.mysql.source.MySqlSource;
import com.ververica.cdc.connectors.mysql.table.StartupOptions;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class MySQLBinlogCustomerSchema {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.enableCheckpointing(1000L);

        MySqlSource mySqlSource = MySqlSource.<String>builder()
                .hostname("localhost")
                .databaseList("flink")
                .tableList("flink.*")
                .port(3306)
                .username("root")
                .password("000000")
                .startupOptions(StartupOptions.latest())
//                .deserializer(new CustomerDeserializationSchema())
                .deserializer(new CustomerSchema())
                .build();

        DataStreamSource streamSource = env.fromSource(mySqlSource, WatermarkStrategy.noWatermarks(), "flink");

        streamSource.print();
        env.execute();
    }
}
